<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>递归实现深拷贝 - 思路</title>
</head>
<body>
    <script>    
        //目标数据
        const school = {
            name: '尚硅谷',
            pos: ['北京','上海','深圳','武汉'],
            founder: {
                name:'刚哥',
                age: 45
            },
            //方法
            improve: function(){
                console.log('提升自己');
            }
        };

        //创建一个容器
        const result = {};

        //添加 name 属性
        result.name = school.name;

        //添加 pos 属性
        result.pos = [];
        result.pos[0] = school.pos[0];
        result.pos[1] = school.pos[1];
        result.pos[2] = school.pos[2];
        result.pos[3] = school.pos[3];

        //添加 founder 属性
        result.founder = {};
        result.founder.name = school.founder.name;
        result.founder.age = school.founder.age;
        
        //improve 方法
        result.improve = school.improve;

        result.pos[0] = 'beijing';

        console.log(school);
        console.log(result);
    </script>
</body>
</html>